
<template>
    <a-row>
        <a-input-search v-model:value="searchKey" placeholder="请输入套管公称尺寸信息" style="width: 250px; margin-bottom: 20px;"
            @search="onSearch()" />
    </a-row>

    <a-table :rowKey="(record) => record.id" :row-selection="rowSelection" :dataSource="dataSource" :columns="columns"
        bordered :pagination="false">
        <template #bodyCell="{ column, text, record }">
            {{ text }}
        </template>
    </a-table>
    <AntdZh>
        <a-pagination v-model:current="query.pageNum" v-model:pageSize="query.pageSize" :total="total" @change="getList" />
    </AntdZh>
</template>
<script setup>
import { ref } from 'vue';
import { cloneDeep } from 'lodash-es';
import { queryList } from "@/api/tool/casing.js";
import useApp from "@/hooks";
const { $, proxy } = useApp();
const total = ref(1)
const data = reactive({
    form: {}
});
const { form } = toRefs(data);
const dataSource = ref([]);
// 定义表格列配置
const columns = [
    {
        title: '套管公称尺寸(in)',
        dataIndex: 'nominalSize',
        key: 'nominalSize',
        width: 200
    },
    {
        title: '套管外径(mm)',
        dataIndex: 'outerDiameter',
        key: 'outerDiameter',
        width: 200
    },
    {
        title: '套管内径(mm)',
        dataIndex: 'innerDiameter',
        key: 'innerDiameter',
        width: 200
    },
    {
        title: '套管通径(mm)',
        dataIndex: 'diameter',
        key: 'diameter',
        width: 200
    },
    {
        title: '套管单位质量(kg/m)',
        dataIndex: 'weight',
        key: 'weight',
        width: 200
    },
];
const searchKey = ref();
const query = ref({ pageNum: 1, pageSize: 10, sortBy: 'id', searchKey: '' });

const rowSelection = {
    type: 'radio',
    onChange: (selectedRowKeys, selectedRows) => {
        console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
        localStorage.setItem("selectCasing", JSON.stringify(selectedRows));
    },
    // getCheckboxProps: record => ({
    //     nominalSize: record.nominalSize,
    // }),
};

/** 查询井列表 */
function getList() {
    queryList(query.value).then((response) => {
        dataSource.value = response.content;
        total.value = response.totalElements;
    });
}
getList();

/** 搜索按钮操作 */
function onSearch() {
    query.value.searchKey = searchKey;
    getList();
}

/** 表单重置 */
// function reset() {
//     searchKey.value = '';
//     query.value = {
//         pageNum: 1, pageSize: 10, sortBy: 'id',
//         searchKey: '',
//     }
//     getList();
// }

</script>
  